package xuegao.study.mall.admin.component;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import org.springframework.stereotype.Component;

@Component
public class FeignLogInterceptor implements RequestInterceptor {

    private final Logger log = LoggerFactory.getLogger(FeignLogInterceptor.class);

    @Override
    public void apply(RequestTemplate template) {
        log.info("feign invoke url:{}", template.url());
        String traceId = MDC.get("traceId");
        String TRACE_ID = "traceId";
        template.header(TRACE_ID, traceId);
    }
}
